Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 29 |
Lines | 54 |
Ratio | 100 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /** global: maxUpload */ |
||
113 | init: function() |
||
114 | { |
||
115 | var myDrop = this; |
||
116 | form.on('submit', function(e, formData) |
||
117 | { |
||
118 | e.preventDefault(); |
||
119 | if(myDrop.getQueuedFiles().length > 0) |
||
120 | { |
||
121 | myDrop.processQueue(); |
||
122 | $('#forProgressBar').show(); |
||
123 | $('.submit-button').attr('disabled', true); |
||
124 | } |
||
125 | else |
||
126 | { |
||
127 | $.post(form.attr('action'), form.serialize(), function(data) |
||
128 | { |
||
129 | uploadComplete(data); |
||
130 | }); |
||
131 | } |
||
132 | }); |
||
133 | this.on('sending', function(file, xhr, formData) |
||
134 | { |
||
135 | var formArray = form.serializeArray(); |
||
136 | $.each(formArray, function() |
||
137 | { |
||
138 | formData.append(this.name, this.value); |
||
139 | }); |
||
140 | }); |
||
141 | this.on('uploadprogress', function(progress) |
||
142 | { |
||
143 | var prog = Math.round(progress.upload.progress); |
||
144 | |||
145 | if(prog != 100) |
||
146 | { |
||
147 | $("#progressBar").css("width", prog+"%"); |
||
148 | $("#progressStatus").text(prog+"%"); |
||
149 | } |
||
150 | // $("#progressBar").css("width", Math.round(progress.upload.progress)+"%"); |
||
151 | // $("#progressStatus").text(Math.round(progress.upload.progress)+"%"); |
||
152 | }); |
||
153 | this.on('reset', function() |
||
154 | { |
||
155 | $('#form-errors').addClass('d-none'); |
||
156 | }); |
||
157 | this.on('success', function(files, response) |
||
158 | { |
||
159 | console.log(response); |
||
160 | uploadComplete(response); |
||
161 | }); |
||
162 | this.on('errormultiple', function(file, response) |
||
163 | { |
||
164 | uploadFailed(response); |
||
165 | }); |
||
166 | } |
||
167 | }); |
||
194 |